package org.example.news_check.Mapper;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.example.news_check.Pojo.Comment;
import org.springframework.stereotype.Repository;

import java.util.List;

// 修改点：移除了 Mapper<Comment> 的泛型
@Repository
@Mapper // 可选：明确标注为 MyBatis Mapper
public interface CommentMapper { // 修改点：不再继承 Mapper<Comment>

    @Select("SELECT * FROM comment WHERE id = #{id}")
    Comment findById(@Param("id") Integer id);

    List<Comment> findBySearch(@Param("search") Comment search, @Param("userId") Integer userId);

    @Select("SELECT * FROM comment WHERE newsId = #{newsId} AND commentId = #{commentId}")
    List<Comment> findByNewsIdAndCommentId(@Param("newsId") Integer newsId, @Param("commentId") Integer commentId);

    int add(Comment comment);

    void delete(Integer id);

    List<Comment> findAll(Integer newsId);

    List<Comment> findByNewsId(Integer newsId);
}
